<template>
	<!-- activitysetting活动设置 -->
	<view class="a_list">
		<view class="a_item" v-for="(item,index) in list" :key="index">
			<view class="a_info">
				<view class="a_title clamp">{{item.title}}</view>
				<view class="a_status" v-if="item.status=='1'">进行中</view>
				<view class="a_status" v-if="item.status=='0'">已结束</view>
			</view>
			<view class="a_time"><text>{{item.begintime}}至{{item.endtime}}</text> <button
					v-if="item.issys=='0'&&item.status=='1'" size="mini"
					@click="$navTo('/pages/business/shopactivitydetails?id='+item.id)">修改</button></view>
			<view class="a_time"><text>创建时间：{{item.createtime}}</text> <button size="mini" type="warn"
					v-if="item.issys=='0'&&item.status=='1'" @click="disableTap(index)">禁用</button></view>
		</view>
		<view class="loading_empty">
			<image v-if="isloading" src="../../static/business/loading.gif" mode=""></image>
			<text v-if="isempty">到底了~</text>
		</view>
		<view class="fbt" @click="$navTo('/pages/business/shopactivitydetails')">添加活动</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 0,
				list: [],

				isloading: false,
				isempty: false,
			}
		},
		onReachBottom() {
			this.getlist();
		},
		onShow() {
			this.page = 0;
			this.list = [];
			this.getlist()
		},
		methods: {
			disableTap(i) {
				let that = this;
				uni.showModal({
					title: '提示',
					content: '确定禁用活动?',
					success(res1) {
						if (res1.confirm) {
							that.$axios('info/saleDisable', 'POST', 'supplier', {
								id: that.list[i].id
							}).then(res => {
								if (res.data.code == 200) {
									that.$api.msg('禁用成功！');
									that.list[i].status = '0';
								}
							})
						}
					}
				})
			},
			getlist() {
				this.page++;
				this.isloading = true;
				this.$axios('info/saleList', 'POST', 'supplier', {
					page: this.page
				}).then(res => {
					this.isloading = false;
					if (res.data.code == 200) {
						let length = res.data.data.length;
						this.list = this.list.concat(res.data.data);
						this.isempty = length <= 0 ? true : false;
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f2f2f2;
		color: $font-color-dark;
		padding-bottom: 120upx;
	}

	.a_list {
		overflow: hidden;
	}

	.a_item {
		background-color: #fff;
		margin-top: 20upx;
		padding: 20upx;
	}

	.a_info,
	.a_time {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.a_status {
		color: #FF0000;
		text-align: center;
		width: 120upx;
		line-height: 60upx;
	}

	.a_time {
		color: $font-color-light;
		padding-top: 10upx;
		line-height: 60upx;
	}

	.a_time button {
		margin: 0;
		width: 120upx;
	}

	.loading_empty {
		color: $font-color-spec;
		text-align: center;
		padding: 40upx;
	}

	.loading_empty image {
		height: 50upx;
		width: 50upx;
	}

	.fbt {
		position: fixed;
		bottom: 20upx;
		left: 3%;
		margin: 0;
	}
</style>
